//
//  LoadMoreCell.m
//  myhuibao
//
//  Created by li jun on 13-4-22.
//  Copyright (c) 2013年 myhuibao. All rights reserved.
//

#import "LoadMoreCell.h"

@implementation LoadMoreCell
@synthesize lbText;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
    }
    return self;
}

-(void)willMoveToSuperview:(UIView *)newSuperview
{
    if (newSuperview) {
            [lbText addObserver:self forKeyPath:@"text" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
        
    }

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


//根据lbtext.text的变化来控制指示的开始与停止
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    
    if([keyPath isEqualToString:@"text"])
    {
        NSLog(@"%@  %@",change[NSKeyValueChangeOldKey],change[NSKeyValueChangeNewKey]);
        if([change[NSKeyValueChangeOldKey] isEqualToString:str_more] && [change[NSKeyValueChangeNewKey] isEqualToString:str_loading])
        {
            [_activity startAnimating];
        }
        else if([change[NSKeyValueChangeOldKey] isEqualToString:str_loading] && [change[NSKeyValueChangeNewKey] isEqualToString:str_more])
        {
            [_activity stopAnimating];
            
        }
       
    }
}



- (void)dealloc
{
    [lbText removeObserver:self forKeyPath:@"text"];
    
}
@end
